/**
 * axios 配置
 */

import axios from "axios";
import Vue from "vue";
import router from "@/router/router";

//应用axios
Vue.prototype.$axios = axios

//相应拦截器
axios.interceptors.response.use(response => {
    // console.log(response);
    if (response.data.code == "0000") {
        router.push({
            path: "/login"
        })
        return response;
    }
    return response;
}, error => {
    if (error.code === 'ECONNABORTED' || error.message === "Network Error" || error.message.includes("timeout")) {
        return Promise.reject("timeOut");
    }
    return Promise.reject(error);
});

axios.defaults.withCredentials = true;


